/**
 * Description:
 * Class Name:DiamondTest
 * Date:2022/3/19 14:55
 *
 * @author LTisme
 * @version JAVA17
 */
package 疯狂Java讲义.第9章_泛型._9_1_泛型入门._9_1_3_Java9增强的菱形语法;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class DiamondTest {
    public static void main(String[] args) {
        // Java编译器会自动推断出ArrayList的<>里应该是String
        List<String > books = new ArrayList<>();
        books.add("the first book");
        books.add("the second book");
        // 遍历books集合，集合元素就是String类型
        books.forEach(str -> System.out.println(str.length()));

        // Java 自动推断出HashMap的<>应该为String，List<String>
        Map<String, List<String>> schoolsInfo = new HashMap<>();
        // Java 自动推断出ArrayList的<>里是String
        List<String> schools = new ArrayList<>();
        schools.add("斜月三星洞");
        schools.add("西天取经路");
        schoolsInfo.put("孙悟空", schools);

        schoolsInfo.forEach((key, value) -> System.out.println(key + "-->" + value));
    }
}
//14
//15
//孙悟空-->[斜月三星洞, 西天取经路]
